namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0029 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.IcmMovement", "DestinationWarehouseId", "dbo.IcmWarehouse");
            DropIndex("dbo.IcmMovement", new[] { "DestinationWarehouseId" });
            AddColumn("dbo.IcmMovement", "SourceEmpId", c => c.Int());
            AddColumn("dbo.IcmMovement", "DestinationJobSiteId", c => c.Int());
            AddColumn("dbo.IcmMovement", "DestinationEmpId", c => c.Int());
            AlterColumn("dbo.IcmMovement", "DestinationWarehouseId", c => c.Int());
            AddForeignKey("dbo.IcmMovement", "DestinationWarehouseId", "dbo.IcmWarehouse", "WhId");
            AddForeignKey("dbo.IcmMovement", "DestinationJobSiteId", "dbo.hrm_mp_job_sites", "job_site_seq");
            AddForeignKey("dbo.IcmMovement", "SourceEmpId", "dbo.hrm_ps_employees", "emp_seq");
            AddForeignKey("dbo.IcmMovement", "DestinationEmpId", "dbo.hrm_ps_employees", "emp_seq");
            CreateIndex("dbo.IcmMovement", "DestinationWarehouseId");
            CreateIndex("dbo.IcmMovement", "DestinationJobSiteId");
            CreateIndex("dbo.IcmMovement", "SourceEmpId");
            CreateIndex("dbo.IcmMovement", "DestinationEmpId");
        }
        
        public override void Down()
        {
            DropIndex("dbo.IcmMovement", new[] { "DestinationEmpId" });
            DropIndex("dbo.IcmMovement", new[] { "SourceEmpId" });
            DropIndex("dbo.IcmMovement", new[] { "DestinationJobSiteId" });
            DropIndex("dbo.IcmMovement", new[] { "DestinationWarehouseId" });
            DropForeignKey("dbo.IcmMovement", "DestinationEmpId", "dbo.hrm_ps_employees");
            DropForeignKey("dbo.IcmMovement", "SourceEmpId", "dbo.hrm_ps_employees");
            DropForeignKey("dbo.IcmMovement", "DestinationJobSiteId", "dbo.hrm_mp_job_sites");
            DropForeignKey("dbo.IcmMovement", "DestinationWarehouseId", "dbo.IcmWarehouse");
            AlterColumn("dbo.IcmMovement", "DestinationWarehouseId", c => c.Int(nullable: false));
            DropColumn("dbo.IcmMovement", "DestinationEmpId");
            DropColumn("dbo.IcmMovement", "DestinationJobSiteId");
            DropColumn("dbo.IcmMovement", "SourceEmpId");
            CreateIndex("dbo.IcmMovement", "DestinationWarehouseId");
            AddForeignKey("dbo.IcmMovement", "DestinationWarehouseId", "dbo.IcmWarehouse", "WhId", cascadeDelete: true);
        }
    }
}
